package com.lingo.dingrobotutils.model.msgBuilder;

import com.dingtalk.api.request.OapiRobotSendRequest;

/**
 * @file: com.lingo.dingRobot.common.model.msgBuilder.DingMarkDownMsgBuilder
 * @Description: 封装 MarkDown 消息类型
 * @author: lingo
 * @version: v1.0
 * @date: 2020/3/23 10:46
 * @Company: www.xyb2b.com
 */

public class DingMarkDownMsgBuilder extends MyDingMsgBuilder {

    private final OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();

    public DingMarkDownMsgBuilder() {
        this.request.setMsgtype("markdown");
        this.request.setMarkdown(markdown);
    }

    public DingMarkDownMsgBuilder setMarkdownTitle(String title){
        if (title != null && !title.isEmpty()){
            this.markdown.setTitle(title);
        }
        return this;
    }

    public DingMarkDownMsgBuilder setMarkdownContent(String content){
        if (content != null && !content.isEmpty()){
            this.markdown.setText(content);
        }
        return this;
    }

    @Override
    public OapiRobotSendRequest build() {
        this.request.setMarkdown(markdown);
        return request;
    }
}
